/**
 * File:   DataTab.java
 * Author: Gvennet
 */
package scenarios.gui.tabs;

import scenarios.gui.NetDataTableModel;
import scenarios.gui.actions.PutValues;
import scenarios.net.TestNode;

import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;
import java.util.concurrent.ScheduledThreadPoolExecutor;

/**
 * todo write javadoc
 */
public final class DataTab
{

	public static JComponent createLocalDataTab(NetDataTableModel dataTableModel, ArrayList<TestNode> nodes, ScheduledThreadPoolExecutor scheduledExecutor)
	{
		JComponent component = new JComponent()
		{

		};

		component.setLayout(new BorderLayout());


		JTable dataTable = new JTable(dataTableModel);

		JButton putButton = new JButton(new PutValues(nodes, scheduledExecutor, dataTableModel));

		JPanel controlPanel = new JPanel();

		GroupLayout layout = new GroupLayout(controlPanel);
		controlPanel.setLayout(layout);

		layout.setAutoCreateGaps(true);
		layout.setAutoCreateContainerGaps(true);

		GroupLayout.SequentialGroup hGroup = layout.createSequentialGroup();

		hGroup.addGroup(layout.createParallelGroup()
				.addGroup(layout.createSequentialGroup()
				.addComponent(putButton)));
		layout.setHorizontalGroup(hGroup);

		GroupLayout.SequentialGroup vGroup = layout.createSequentialGroup();

		vGroup.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
				.addComponent(putButton));
		layout.setVerticalGroup(vGroup);


		FlowLayout flowLayout = new FlowLayout();
		flowLayout.setAlignment(FlowLayout.LEFT);

		component.add(BorderLayout.SOUTH, controlPanel);
		component.add(BorderLayout.CENTER, new JScrollPane(dataTable));

		component.setVisible(true);

		component.setVisible(true);

		return component;

	}

}